-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Transform String Resugar Term Scott #714
Conversation
…ndling * Introduce trait, allowing definition of visitors for different Term processing logics. * Create struct to wrap user-provided cons handling functions, implementing the trait. * Implement struct to handle default cons patterns, also implementing the trait. * Replace with type, better expressing success or failure semantics. * Utilize Rust's pattern matching and method to simplify error handling process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visitor is completely unnecessary here, doesn't really simplify.
I like the idea of the try_resugar
functions, it lets the pattern matching not be repeated twice.
You could have a single build_string
function that takes takes the encoding, tries the correct encoded pattern and tries the non-applied constructors, without repetition.
Also, please leave the if
tree since it mimics the shape of the AST and is easier for me to visualize the structure.
… the shape of the AST visualize the structure
… the shape of the AST visualize the structure
Done Please review~~thx @developedby |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nicer to read without the visitor, but my other previous comments still apply.
Also, please do the changes on resugar_list
as well. It's almost an exact copy of this one, just looking for a slightly different pattern. It would be confusing if they were implemented differently
src/fun/transform/resugar_string.rs
Outdated
} | ||
|
||
// Cons: @x (x CONS_TAG <num> <str>) | ||
if let Term::Lam { tag: Tag::Static, pat, bod } = current { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is specifically the "num-scott" encoding, you shouldn't apply it for all cases
In the |
…ics the shape of the AST for easier visualization
…ics the shape of the AST for easier visualization
Co-authored-by: Nicolas Abril <[email protected]>
Can you just run |
… the shape of the AST visualize the structure && cargo fmt
|
Thank you very much for the contribution |
#713